<template>
	<view>
		<!-- <picker type='1' @change="selCity" @columnchange="selMonitor" :value="addressIndex" :range="address" mode="multiSelector">
		  <view class="setCon">
		    <input type="text" :value="addressNode.province + addressNode.city" disabled="" />
		    <icon class="iconfont iconkefu"></icon>
		  </view>
		</picker> -->
		<view class="" @click="open">
			2222
		</view>
		<picker ref="picker" mode="multiSelector" :range="AddressRange">
				打开
		</picker>
	</view>
</template>

<script>
	// ********************************************
	// 暂不可用
	// ********************************************
	// 导入全国省市区集合
	import address from './address.json';
	export default {
		data() {
			return {
				address: [],
				provinceList: [],
				cityAllList: [],
				addressIndex: [0, 0],
				addressNode: {
					province: "请选择城市",
					city: ""
				},
				AddressRange: [
					[1, 2],
					[2, 3]
				],
				aa: false
			};
		},
		onLoad() {
			const that = this
			// 将省市区的数据转换为picker可用的多维数组
			that.getAddressData()
		},
		methods: {
			open() {
				// this.$refs.picker
				console.log(22222222);
				this.aa = true
			},
			// 获取地址信息
			selCity(e) {
				const that = this;
				let val = e.target.value
				that.addressNode = {
					province: that.address[0][val[0]],
					city: that.address[1][val[1]]
				}
			},
			// 监听省市区滚动
			selMonitor(e) {
				const that = this
				let column = e.detail.column
				if (column == 0) {
					let index = e.detail.value
					that.address[1] = that.cityAllList[index]
				}
			},
			// 将省市区的数据转换为picker可用的多维数组
			getAddressData() {
				const that = this;
				// 所有城市列表,二维数组
				let cityAllList = [];
				// 省列表
				let provinceList = [];
				// address为省市区的json数据
				for (let key in address) {
					let newDataList = [];
					if (address[key].children) {
						for (let key2 in address[key].children) {
							newDataList.push(address[key].children[key2].name);
						}
					}
					provinceList.push(address[key].name);
					cityAllList.push(newDataList);
				}
				that.provinceList = provinceList;
				that.cityAllList = cityAllList;
				that.address = [provinceList, cityAllList[0]];
				console.log('that.address', that.address);
			}
		}
	};
</script>

<style>

</style>